using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using Entites;

namespace BUS
{
  public  class HinhAnhBUS
    {
       public static void Insert(HinhAnh ha)
        {
          HinhAnhDAL haDAL = new HinhAnhDAL();
            haDAL.Insert(ha);
        }
        public static void Update(HinhAnh ha)
        {
            HinhAnhDAL haDAL = new HinhAnhDAL();
            haDAL.Update(ha);
        }
        public static void Delete(int iD)
        {
            HinhAnhDAL haDAL = new HinhAnhDAL();
            haDAL.Delete(iD);
        }
        public static tbHinhAnhCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            HinhAnhDAL haDAL = new HinhAnhDAL();
            return haDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhAnhCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhAnhDAL haDAL = new HinhAnhDAL();
            return haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.MaHinhAnh.ToString(), OrderDirection.ASC.ToString(), out total);
        }
      public static HinhAnh GetByID(int iD)
      {
          int total = 0;
          Criteria cri = new Criteria();
          cri.add(Condition.AND, tbHinhAnhColumns.MaHinhAnh.ToString(), Condition.EQUAL, iD);
          HinhAnhDAL haDAL = new HinhAnhDAL();
          tbHinhAnhCollection hinhanhcollection = haDAL.Get(cri.Criter,
                0, 0, tbHinhAnhColumns.MaHinhAnh.ToString(), OrderDirection.ASC.ToString(), out total);
          if (hinhanhcollection.Count > 0)
              return hinhanhcollection[0];
          return null;
      }
      
        public static tbHinhAnhCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhAnhDAL haDAL = new HinhAnhDAL();
            return haDAL.Get(cri.Criter, 1, number,
             tbHinhAnhColumns.MaHinhAnh.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbHinhAnhCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhAnhDAL haDAL = new HinhAnhDAL();
            return haDAL.Get(cri.Criter, 1, number,
               tbHinhAnhColumns.MaHinhAnh.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
    
}
